<template>
  <div px-16rpx>
    <div>
      <!-- <order /> -->
      <div bg-white p-36rpx>
        <column v-if="applyInfo" :res="applyInfo" :price="applyInfo.goodsPrice" :image="applyInfo.image" />
      </div>
    </div>
    <div v-for="(item, index) in applyList" :key="index">
      <div my-20rpx p-36rpx card flex flex-a-c flex-j-sb
        @click="$navigateTo(`/pages/mine/aftersale/workflow?type=${item.value}&sn=${sn}`)" v-if="item.enable">
        <div font-bold text-30rpx>{{ item.label }}</div>
        <div text-24rpx color-warmgray flex flex-a-c>
          {{ item.content }}
          <nut-icon size="12" name="rect-right"></nut-icon>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { getAfterSaleInfo } from "@/api/after-sale";
import column from "@/components/goods-list/column.vue";
import { onLoad } from "@dcloudio/uni-app";
const applyInfo = ref<any>("")
const sn = ref<string>('')
const applyList = ref<any>([{
  label: "退货",
  value: "RETURN_GOODS",
  key: "returnGoods",
  enable: false,
  content: "退回收到的商品"
}, {
  label: "退款",
  value: "RETURN_MONEY",
  key: "returnMoney",
  content: "退款商品返还金额",
  enable: false,
},
])


async function init(sn: string) {
  const res = await getAfterSaleInfo(sn)
  if (res.data.success) {
    applyInfo.value = res.data.result
    applyList.value.forEach((item: any) => {
      if (res.data.result[item.key]) {
        item.enable = true
      }
    })
  }
}

onLoad((options: any) => {
  // 初始化数据
  sn.value = options.sn
  init(options.sn)
})
</script>

<style scoped>
</style>
